
$(if $(code_root),,$(error code_root must set))
projects := $(shell cd $(code_root) && find xts_acts_arkts1.2 -name hvigor | xargs dirname )
# code_root := $(CURDIR)
hap_out_dir := $(code_root)/xts_haps
log_dir := $(code_root)/logs

$(warning code_root = $(code_root))
$(warning projects = $(projects))

.PHONY: $(projects) all

all: $(projects)

prepare:
	mkdir -pv $(hap_out_dir) $(log_dir)

sdk:prepare
	-time (cd $(code_root)/ && applications/standard/hap/build.sh --build_sdk=1) &> $(log_dir)/ohos_sdk.log

$(projects): sdk
	@echo project = $@, hap_name=$(shell basename $@)
	-time (cd $(code_root)/ && applications/standard/hap/build.sh --build_sdk=true --project=$(code_root)/$@ --out_path=$(hap_out_dir)/$(shell basename $@)) &> $(log_dir)/$(shell basename $@).log
	-mv $(hap_out_dir)/$(shell basename $@)/entry-default-signed.hap $(hap_out_dir)/$(shell basename $@).hap
	-rm -rfv $(hap_out_dir)/$(shell basename $@)
